function res = constrain(num,max, min)
%UNTITLED3 Summary of this function goes here
%   Detailed explanation goes here
res = zeros(length(num), 1);
for i = 1:length(num)
    if(num(i)>max)
        res(i) = max;
    elseif(num(i)<min)
        res(i) = min;
    else
        res(i) = num(i);
    end
end
end